#include "DeviceVertice.h"
#include <thrust\transform.h>
#include <thrust\device_ptr.h>




typedef struct device_rigidTransform{
	device_rigidTransform(cameraPose* pos){
		this->pos = pos;
	}

	__host__ __device__ float3 operator()(float3 in_out){
		float temp[3];
		for(int i = 0; i < 3; i++)
			temp[i] =	in_out.x * pos->data[i] + 
						in_out.y * pos->data[i + 4] + 
						in_out.z * pos->data[i + 8] + 
						pos->data[i + 12];
		
		in_out.x = temp[0];
		in_out.y = temp[1];
		in_out.z = temp[2];

		return in_out;
	}

	cameraPose* pos;
};


void DeviceVertice::applyRigidTransformation(cameraPose* pos){
	thrust::transform(
		thrust::device_ptr<float3>(data),
		thrust::device_ptr<float3>(data) + num,
		thrust::device_ptr<float3>(data),
		device_rigidTransform(pos)
	);
}